package com.echo.im.offlinePush.config;

import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author echo
 */
@Configuration
public class RabbitConfig {

    @Bean
    public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactoryWithPrefetch(ConnectionFactory connectionFactory) {
        SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
        factory.setConnectionFactory(connectionFactory);
        factory.setPrefetchCount(200);  // 配置预取值为100
        factory.setBatchSize(200);
        factory.setConsumerBatchEnabled(true);
        factory.setConcurrentConsumers(3);
        factory.setBatchListener(true); // 启用批量监听
        return factory;
    }


}